package com.eascs.workflow.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.admin.common.service.ILoanInfoService;
import com.eascs.admin.o2o.loan.dao.O2oLoanapplyDao;
import com.eascs.admin.o2o.loan.dao.O2oSdDao;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.loan.dao.O2oLoanDao;
import com.eascs.loan.form.O2oLoanForm;
import com.eascs.workflow.form.SDEntity;
import com.eascs.workflow.form.SDForm;
/**
 * 动态表单 Service
 * @author ycz
 *
 */
@Service
public class WorkFlowSumbitService {
	@Autowired
	private O2oLoanapplyDao o2oLoanapplyDao;
	@Autowired
	private O2oSdDao o2oSdDao;
	@Autowired 
	private O2oLoanDao o2oLoanDao;
	@Reference
	ILoanInfoService iLoanInfoService;
	
	/**
	 * 征信 财务审核表单 提交
	 * @param sdForm
	 * @param sd
	 */
	@Transactional(transactionManager = "o2oTransactionManager")
	public void updateZxPTCW(SDForm sdForm, SDEntity sd){
		if(sdForm!=null){
			if(sdForm.getId()==null){
				o2oSdDao.insert(sd);
			}else{
				o2oSdDao.updateSDEntity(sd);
			}
		}
		o2oLoanapplyDao.updateO2oFinanceExamine(sdForm);
	}
	/**
	 * 银行放款--申报
	 * @param o2oloanForm 
	 * @param o2oloanapply 
	 * 
	 * @param yhssForm
	 * @return
	 */
	@Transactional(transactionManager = "o2oTransactionManager")
	public void updatePayment(O2oLoanapplyEntity o2oloanapply, O2oLoanForm o2oloanForm){
		o2oLoanapplyDao.updateById(o2oloanapply);
		o2oLoanDao.saveLoan(o2oloanForm);
		o2oLoanapplyDao.updateO2oloanapplyBanknum(o2oloanapply.getLoanId());
	}
	public Map<String, String> saveLoan(O2oLoanForm o2oloanForm){
		return o2oLoanDao.saveLoan(o2oloanForm);
	}
}
